﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Wicresoft.Busi.BizLogic;
using Wicresoft.Busi.Entity;

public partial class NewMeetingRoom_RoomUseList : BaseAuthenticationPage
{
    #region Property RoomID
    public int RoomID
    {
        get
        {
            if (Request["RoomID"] != null)
                return int.Parse(Request["RoomID"].ToString());
            else
                return int.MinValue;
        }

    }
    #endregion

    #region Property Date
    public string Date
    {
        get
        {
            if (ViewState["Date"] == null)
            {
                if (Request["Date"] == null)
                    ViewState["Date"] = DateTime.Now.ToString("yyyy-MM-dd");
                else
                    ViewState["Date"] = Request["Date"];
            }
            return ViewState["Date"].ToString();
        }
    }
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        this.UseTabber = true;
        if (!IsPostBack)
        {
            this.dgApply.GotoButtonCssClass = "Button01";
            this.dgApply.GotoInputCssClass = "TextBox01";
            loadRoomInfo();

        }
    }

    protected void Page_PreRender(object sender, EventArgs e)
    {
        this.dgApply.Order = vwMeetingRoomApply.SQLCOL_MEETINGDATE + "," + vwMeetingRoomApply.SQLCOL_STARTTIME;
    }


    protected DataTable dgApply_OnGetData(object sender, Wicresoft.Web.UI.WebControls.GetDataEventArgs e)
    {
        string[] strMeetingStatus = new string[] { MeetingStatus.POST, MeetingStatus.AUDIT };
        return BLMeetingRoomApply.GetMeetingRoomApplyByRoomID(RoomID, Date, strMeetingStatus, CurrentUser.ID, e.Paging);
    }

    #region 根据当前选中的会议室,读取会议室详细信息
    private void loadRoomInfo()
    {
        MeetingRooms info = new MeetingRooms(RoomID);
        if (info.Exist())
        {
            info.Load();
            this.lblRoomType.Text = BLDic_MeetingRoom.GetPropertyName(MeetingRoomPropertyType.ROOMTYPE, info.RoomType);
            this.lblRoomName.Text = info.RoomName;
            this.lblLocation.Text = info.Location;
            this.lblSeatsCount.Text = info.SeatsCount.ToString();
            if (info.Picture == null || info.Picture.Equals(string.Empty))
                this.imgRoom.ImageUrl = "../images/NoPreview.jpg";
            else
            {
                this.imgRoom.ImageUrl = "../images/MeetingRooms/" + info.Picture;
                this.hlImg.HRef = "../images/MeetingRooms/" + info.Picture;
            }
        }
        else
        {
            this.lblRoomType.Text = string.Empty;
            this.lblRoomName.Text = string.Empty;
            this.lblLocation.Text = string.Empty;
            this.lblSeatsCount.Text = string.Empty;
            this.imgRoom.ImageUrl = "../images/NoPreview.jpg";
        }
    }
    #endregion
}
